#pragma once

// Helper classes for automatic release of locks

struct exclusive_lock_t
{
    exclusive_lock_t(PSRWLOCK plock) : _plock(plock) { AcquireSRWLockExclusive(_plock); }
    ~exclusive_lock_t() { ReleaseSRWLockExclusive(_plock); }
private:
    PSRWLOCK _plock;
};

struct shared_lock_t
{
    shared_lock_t(PSRWLOCK plock) : _plock(plock) { AcquireSRWLockShared(_plock); }
    ~shared_lock_t() { ReleaseSRWLockShared(_plock); }
private:
    PSRWLOCK _plock;
};

